<template>
	<view>
		<view style="height: 10px;"></view>
		
		<!--身份为发布方-->  <!--发布方 其 参与方了缴纳保证金 ， 参与方出现了问题， 发布方向 参与方申请 售后页面 -->
		<block v-if="is_publisherApply==true">
			<publisherApply :text="text" :order="orderDetail" @change="changeTab" :afterSalesRecord="afterSalesRecord" :is_publisherApply_edit="is_publisherApply_edit"
			:customStyle1="customStyle1" :customStyle11="customStyle11" 
			:customStyle2="customStyle2" :customStyle3="customStyle3">
			</publisherApply>
		</block>
		
		
		<!--身份为发布方-->  <!-- 发布方 申请 提交表单 后 ，显示 页面 -->
		<block v-if="is_publisherShow==true">
			<publisherShow :text="text" :order="orderDetail" @change="changeTab" :afterSalesRecord="afterSalesRecord"
			:customStyle1="customStyle1" :customStyle11="customStyle11" 
			:customStyle2="customStyle2" :customStyle3="customStyle3"></publisherShow>
		</block>
		
		
		<!--身份为发布方-->  <!-- 发布方 申请 提交表单 后 ，参与方 认可 显示的 售后成功界面 -->
		<block v-if="is_publisherSuccess==true">
			<publisherSuccess :text="text" :order="orderDetail" :afterSalesRecord="afterSalesRecord"
			:customStyle1="customStyle1" :customStyle11="customStyle11" 
			:customStyle2="customStyle2" :customStyle3="customStyle3"></publisherSuccess>
		</block>
		
		<!--身份为发布方-->  <!-- 发布方 申请 提交表单 后 ，参与方 不认可 显示的 参与方申诉界面 -->
		<block v-if="is_publisherDoing==true">
			<publisherDoing :text="text" :order="orderDetail" :afterSalesRecord="afterSalesRecord" @change="changeTab"
			:customStyle1="customStyle1" :customStyle11="customStyle11" 
			:customStyle2="customStyle2" :customStyle3="customStyle3"></publisherDoing>
		</block>
		
		
		
		<!--身份为参与方-->  <!-- 参与方收到 发布方 申请 的售后 ， 但此时  参与方未处理页面-->
		<block v-if="is_waitCooperateHandle==true">
			<waitCooperateHandle :text="text" :order="orderDetail" @change="changeTab" :afterSalesRecord="afterSalesRecord"
			:customStyle1="customStyle1" :customStyle11="customStyle11" 
			:customStyle2="customStyle2" :customStyle3="customStyle3">
			</waitCooperateHandle>
		</block>
		
		
		<!--中间有参与方提交 申诉界面   cooperateApply -->
		
		
		<!--身份为参与方-->  <!-- 参与方收到 发布方 申请 的售后 ， 觉得不对  提交申诉表单 给 发布方后   等待发布方处理页面-->
		<block v-if="is_cooperateAppeal_bool==true">
			<cooperateAppeal :text="text" :order="orderDetail" @change="changeTab" :afterSalesRecord="afterSalesRecord"
			:customStyle1="customStyle1" :customStyle11="customStyle11" 
			:customStyle2="customStyle2" :customStyle3="customStyle3">
			</cooperateAppeal>
		</block>
		
		
		<!--身份为参与方-->  <!-- 参与方收到 发布方 申请 的售后 ， 觉得不对  提交申诉表单 给 发布方后 ，  发布方不同意操作 处理后  显示结果 页面-->
		<block v-if="is_cooperateAppeal_bool2==true">
			<cooperateAppeal2 :text="text" :order="orderDetail" @change="changeTab" :afterSalesRecord="afterSalesRecord" 
			:is_cooperateAppeal_bool3="is_cooperateAppeal_bool3"
			:customStyle1="customStyle1" :customStyle11="customStyle11" 
			:customStyle2="customStyle2" :customStyle3="customStyle3">
			</cooperateAppeal2>
		</block>
	
	
		<block v-if="is_cooperateSuccess==true">
			<cooperateSuccess :text="text" :order="orderDetail" :afterSalesRecord="afterSalesRecord"
			:customStyle1="customStyle1" :customStyle11="customStyle11" 
			:customStyle2="customStyle2" :customStyle3="customStyle3"></cooperateSuccess>
		</block>

		
	</view>
</template>


<script>
	import {HTTP_REQUEST_URL,HTTP_IMG_UTL,IMAGE_URL} from "@/config/app";
	import publisherApply from "./customer/publisherApply.vue"
	import publisherShow from "./customer/publisherShow.vue"
	import publisherSuccess from "./customer/publisherSuccess.vue"
	import publisherDoing from "./customer/publisherDoing.vue"
	import waitCooperateHandle from "./customer/waitCooperateHandle.vue"
	import cooperateAppeal from "./customer/cooperateAppeal.vue"
	import cooperateAppeal2 from "./customer/cooperateAppeal2.vue"
	import cooperateSuccess from "./customer/cooperateSuccess.vue"
	
	export default {
		components: {
			publisherApply,waitCooperateHandle,cooperateAppeal,cooperateAppeal2,publisherShow,publisherSuccess,publisherDoing,cooperateSuccess
		},
		data() {
			return {
				//远程域名
				HTTP_IMG_UTL,
				HTTP_REQUEST_URL,
				IMAGE_URL,
				url: IMAGE_URL,
				
				//语言
				lang: this.$i18n.locale,
				//文字
				text:{			
					title:this.$t('申请售后订单'),
					order_no:this.$t('订单编号'),
					order_type:this.$t('订单类型'),
					peifu:this.$t('赔付申请'),
					baozhengjin:this.$t('保证金补偿'),
					upload_pic:this.$t('上传证据'),
					submit_user:this.$t('提交人'),
					apply:this.$t('申请说明'),
					burenke:this.$t('不认可售后结果，提起申诉'),
					automatic_agree:this.$t('72:00:00后自动同意'),
					afterReason:this.$t('售后原因'),
					afterAppeal:this.$t('售后申诉'),
					afterNoAppeal:this.$t('不认可本次申诉'),
					ReasonAppeal:this.$t('申诉理由'),
					otherAppeal:this.$t('发起申诉'),
					afterEdit:this.$t('修改了售后申请'),
					afterAgree:this.$t('认可本次售后申请'),
					afterNoAgree:this.$t('不认可本次售后申请，发起申诉'),
					system:this.$t('系统提示'),
					system_show:this.$t('售后申请通过后，保证金将在7-15个工作日内赔付至您的账户内，请注意查收。'),
					system_show2:this.$t('售后申请已通过，您的保证金将在7-15个工作日内赔付至对方账户，赔付后您可在保证金账单内查看退回保证金。')
				},
				
				img:HTTP_IMG_UTL+'huangjin.png',
				subDisabled:false,
				
				customStyle1: {
					width: '255rpx',
					height: '83rpx',
					marginTop:'20rpx',
					fontSize:'24rpx',
					background: '#008aff',
					borderRadius: '56rpx'
				},
				customStyle11: {
					width: '255rpx',
					height: '83rpx',
					marginTop:'20rpx',
					fontSize:'24rpx',
					background: '#ff2323',
					borderRadius: '56rpx'
				},
				customStyle2: {
					width: '500rpx',
					height: '83rpx',
					marginTop:'20rpx',
					fontSize:'24rpx',
					background: '#ff2323',
					borderRadius: '56rpx'
				},
				customStyle3: {
					width: '255rpx',
					height: '83rpx',
					marginTop:'20rpx',
					fontSize:'24rpx',
					background: 'gray',
					borderRadius: '56rpx'
				},
				
				//参与订单id
				join_order_id:0,
				//订单id
				order_id:0,
				//订单详情
				orderDetail:{},
				
				//售后记录
				afterSalesRecord:{},
				//修改售后申请标志位
				is_publisherApply_edit:0,
				
				//身份为发布方  发布方 其 参与方了缴纳保证金 ， 参与方出现了问题， 发布方向 参与方申请 售后页面 
				is_publisherApply:false,
				//身份为发布方 发布方 申请 提交表单 后 ，显示 页面 	
				is_publisherShow:false,
				//身份为发布方 发布方 申请 提交表单 后 ，参与方 不认可 显示的 参与方申诉界面 
				is_publisherDoing:false,
				
				// 身份为参与方 参与方收到 发布方 申请 的售后 ， 但此时  参与方未处理页面
				is_waitCooperateHandle:false,
				//身份为参与方 参与方收到 发布方 申请 的售后 ， 觉得不对  提交申诉表单 给 发布方后   等待发布方处理页面
				is_cooperateAppeal_bool:false,
				
				//身份为参与方 参与方收到 发布方 申请 的售后 ， 觉得不对  提交申诉表单 给 发布方后 ，  发布方不同意操作 处理后  显示结果 页面
				is_cooperateAppeal_bool2:false,
				
				//身份为参与方 参与方收到 发布方 申请 的售后 ， 觉得不对  提交申诉表单 给 发布方后 ， 发布方不同意 但修改了自己的申请操作 显示结果 页面
				is_cooperateAppeal_bool3:false,
				
				is_publisherSuccess:false,
				is_cooperateSuccess:false
				
			}
		},
		onLoad(options){
			if(options){
				this.order_id = options.order_id
				this.join_order_id = options.join_order_id
				this.getCooperationOrderDetail()
			}
		},
		onReady() {
			uni.setNavigationBarTitle({		//自定义标题
				title: this.$t('售后服务')
			})
		},
		methods:{
			//合作订单详情
			getCooperationOrderDetail(){
				const that = this
				that.$u.api.order.getCooperationOrderDetail({
					id: that.join_order_id,
					lang:that.lang
				}).then(res => {
					that.orderDetail=res
					
					if((that.orderDetail.orderInfo.aftersales_id==null)||(that.orderDetail.orderInfo.aftersales_id==0)){
						that.is_publisherApply=true
					}else{
						
						that.$u.api.order.afterSalesRecord({
							aftersales_id: that.orderDetail.orderInfo.aftersales_id,
							lang:that.lang
						}).then(result => {
							that.afterSalesRecord = result

							if(!that.afterSalesRecord.appeal_description){
								//参与方
								if(that.orderDetail.user_id != that.orderDetail.release_user.id){
									that.is_waitCooperateHandle = true
									
									//同意认可
									if((that.afterSalesRecord.release_status==1)||(that.afterSalesRecord.join_status==1)){
										that.is_publisherApply = false
										that.is_publisherShow = false
										that.is_publisherDoing = false
										that.is_waitCooperateHandle = false
										that.is_cooperateAppeal_bool = false
										that.is_cooperateAppeal_bool2 = false
										that.is_cooperateAppeal_bool3 = false
										that.is_cooperateSuccess = true
									}
									
									
								}else{
									//发布方
									that.is_publisherShow = true
									
									
									//同意认可
									if((that.afterSalesRecord.release_status==1)||(that.afterSalesRecord.join_status==1)){
										that.is_publisherApply = false
										that.is_publisherShow = false
										that.is_publisherDoing = false
										that.is_waitCooperateHandle = false
										that.is_cooperateAppeal_bool = false
										that.is_cooperateAppeal_bool2 = false
										that.is_cooperateAppeal_bool3 = false
										that.is_publisherSuccess = true
									}
								}

							}else{
																
								//参与方
								if(that.orderDetail.user_id != that.orderDetail.release_user.id){
									that.is_waitCooperateHandle = false
									that.is_cooperateAppeal_bool = true
									
									if((that.afterSalesRecord.release_status==2)&&(that.afterSalesRecord.is_publisherApply_edit==0)){
										that.is_waitCooperateHandle = false
										that.is_cooperateAppeal_bool = false
										that.is_cooperateAppeal_bool2 = true
									}
									if((that.afterSalesRecord.release_status==2)&&(that.afterSalesRecord.is_publisherApply_edit==1)){
										that.is_waitCooperateHandle = false
										that.is_cooperateAppeal_bool = false
										that.is_cooperateAppeal_bool2 = true
										that.is_cooperateAppeal_bool3 = true
									}
									
									//同意认可
									if((that.afterSalesRecord.release_status==1)||(that.afterSalesRecord.join_status==1)){
										that.is_publisherApply = false
										that.is_publisherShow = false
										that.is_publisherDoing = false
										that.is_waitCooperateHandle = false
										that.is_cooperateAppeal_bool = false
										that.is_cooperateAppeal_bool2 = false
										that.is_cooperateAppeal_bool3 = false
										that.is_cooperateSuccess = true
									}
									
									
									
								}else{
									//发布方
									that.is_publisherShow = false
									that.is_publisherDoing  = true
									
									//同意认可
									if((that.afterSalesRecord.release_status==1)||(that.afterSalesRecord.join_status==1)){
										that.is_publisherApply = false
										that.is_publisherShow = false
										that.is_publisherDoing = false
										that.is_waitCooperateHandle = false
										that.is_cooperateAppeal_bool = false
										that.is_cooperateAppeal_bool2 = false
										that.is_cooperateAppeal_bool3 = false
										that.is_publisherSuccess = true
									}
									
									
								}
							
							}
							
						})
						
					}
				})
			},
			changeTab(e,data,res=0){
				const that = this
				console.log(e,data,res)
				if(data=='publisherApply'){
					that.is_publisherApply=false
					that.$u.api.order.afterSalesRecord({
						aftersales_id: res,
						lang:that.lang
					}).then(result => {
						that.afterSalesRecord = result
						
						//参与方
						if(that.orderDetail.user_id != that.orderDetail.release_user.id){
							that.is_waitCooperateHandle = true
						}else{
							//发布方
							that.is_publisherShow = true
						}
						
					})
				}else if(data=='publisherApply2'){
					that.is_publisherApply=false
					that.$u.api.order.afterSalesRecord({
						aftersales_id: res,
						lang:that.lang
					}).then(result => {
						that.afterSalesRecord = result

						//参与方
						if(that.orderDetail.user_id != that.orderDetail.release_user.id){
							that.is_waitCooperateHandle = false
							that.is_cooperateAppeal_bool = true
						}else{
							//发布方
							that.is_publisherShow = false
							that.is_publisherDoing  = true
						}
	
					})
					
				}else if(data=='publisherEdit'){
					//参与方
					if(that.orderDetail.user_id != that.orderDetail.release_user.id){
						that.is_waitCooperateHandle = false
					}else{
						//发布方
						that.is_publisherShow = false
					}
					that.afterSalesRecord = res
					that.is_publisherApply = true
				
				}else if(data=='publisherEdit2'){
					//参与方
					if(that.orderDetail.user_id != that.orderDetail.release_user.id){
						that.is_waitCooperateHandle = false
					}else{
						//发布方
						that.is_publisherShow = false
					}
					that.afterSalesRecord = res
					that.is_publisherDoing = false
					that.is_publisherApply_edit = 1
					that.is_publisherApply = true
					
				}else if(data=='approve'){
					that.is_publisherApply = false
					that.is_publisherShow = false
					that.is_publisherDoing = false
					that.is_waitCooperateHandle = false
					that.is_cooperateAppeal_bool = false
					that.is_cooperateAppeal_bool2 = false
					that.is_cooperateAppeal_bool3 = false
					//参与方
					if(that.orderDetail.user_id != that.orderDetail.release_user.id){
						that.getCooperationOrderDetail()
					}else{
						//发布方
						that.getCooperationOrderDetail()
					}
				}
			}
		}
	}
</script>
